home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / basic / PureBasic_Upd.lha / PureBasic_Update1.60 / PureBasic / Examples / Sources / PTModule.pb < prev    next >
Encoding:
Text File  |  2000-09-10  |  2.9 KB  |  155 lines

  1. ;
  2. ; ********************************************
  3. ;
  4. ; Protracker Module example file for PureBasic
  5. ;
  6. ;       © 2000 - Fantaisie Software -
  7. ;
  8. ; ********************************************
  9. ;
  10. ;
  11.  
  12. Structure PTModule
  13.  Status.w : Mod_Nr.w
  14.  Name.s
  15. EndStructure
  16.  
  17.  NewList Module.PTModule()
  18.  
  19.  
  20.  nr_args.w=NumberOfCLIArgs()
  21.  
  22.  If nr_args.w
  23.  
  24.    ptmods.l=nr_args.w-1
  25.  
  26.    If InitAudio() AND InitPTModule(ptmods.l) AND InitSound(0)
  27.  
  28.      If AllocateAudioChannels(15)
  29.  
  30.        For c.l=0 To ptmods.l
  31.          AddElement(Module())
  32.          name$=GetCLIArg$(c.l+1)
  33.  
  34.          CLR.l  d2 
  35.  
  36.          If LoadPTModule(c.l,name$)
  37.            Module()\Mod_Nr=c.l
  38.            Module()\Name="Module " + Str(c.l) + "."
  39.          EndIf
  40.  
  41.        Next c.l
  42.  
  43.        LoadSound(0,"PureBasic:Examples/Data/Bump.IFF")
  44.  
  45.        pt_chan.w=15
  46.        FirstElement(Module())
  47.        UseAsPTModuleChannels(pt_chan.w)
  48.  
  49.        Module()\Status=1
  50.        mod.w=Module()\Mod_Nr
  51.        PlayPTModule(mod.w)
  52.  
  53.        Repeat
  54.  
  55.          VWait() : VWait()
  56.          mb.w=MouseButtons()
  57.  
  58.          pos.w=GetPTModulePos()
  59.          row.w=GetPTModuleRow()
  60.          Print(" - Pos ") : PrintNumber(pos.w)
  61.          Print(" - Row ") : PrintNumberN(row.w)
  62.  
  63.  
  64.          If mb.w = 1
  65.  
  66.            PrintN("")
  67.            PrintN(" - Module: LMB  - Sound: RMB")
  68.            Delay(15)
  69.  
  70.            Repeat
  71.              VWait() : VWait()
  72.              mb.w=MouseButtons()
  73.            Until mb.w
  74.  
  75.            If mb.w = 1
  76.  
  77.              PausePTModule()
  78.              MOVE.w #15,$dff096
  79.  
  80.              If NextElement(Module()) = 0
  81.                FirstElement(Module())
  82.              EndIf
  83.  
  84.              mod.w=Module()\Mod_Nr
  85.  
  86.              If Module()\Status = 0
  87.                PlayPTModule(mod.w)
  88.                Module()\Status=1
  89.                PrintN(" - Play "+Module()\Name)
  90.              Else
  91.                ResumePTModule(mod.w)
  92.                PrintN(" - Resume "+Module()\Name)
  93.              EndIf
  94.  
  95.            EndIf
  96.  
  97.            If mb.w = 2
  98.              chan.w=PlaySound(0,1)
  99.              If chan.w
  100.                PrintN(" - Playing Sound...")
  101.              Else
  102.                PrintN(" - No channels...")
  103.              EndIf
  104.            EndIf
  105.  
  106.            mb.w=0 : Delay(25) 
  107.          EndIf
  108.  
  109.  
  110.          If mb.w = 2
  111.  
  112.            PrintN("")
  113.            PrintN(" - Channel + 1: LMB  - Channel LSL 1: RMB")
  114.            Delay(15)
  115.  
  116.            Repeat
  117.              VWait() : VWait()
  118.              mb.w=MouseButtons()
  119.            Until mb.w
  120.  
  121.            If mb.w = 1
  122.              (pt_chan.w+1) & 15
  123.            EndIf
  124.  
  125.  
  126.            If mb.w = 2
  127.              pt_chan.w LSL 1 & 15
  128.            EndIf
  129.  
  130.            s_chan.w=pt_chan.w & 15
  131.  
  132.            Print(" - PTModuleChannels=") : PrintNumber(pt_chan.w)
  133.            UseAsPTModuleChannels(pt_chan.w)
  134.  
  135.            Print(" SoundChannels=") : PrintNumberN(s_chan.w)
  136.            UseAsSoundChannels(s_chan.w)
  137.  
  138.            Delay(50)
  139.          EndIf
  140.  
  141.        Until mb.w = 3
  142.  
  143.  
  144.      Else
  145.        PrintN("Can't Allocate Channels.")
  146.      EndIf
  147.  
  148.    EndIf
  149.  
  150.  EndIf
  151.  
  152.  PrintN("End of Program.")
  153.  End
  154.  
  155.